package spoon.task;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import spoon.core.domain.Game;
import spoon.service.Bet365Service;

@Component
public class Bet365FootballTask {

	@Autowired
	@Qualifier("bet365FootballService")
	private Bet365Service bet365Service;
	
	private List<Game> leagueList = new ArrayList<Game>();
	
	//@Scheduled(fixedRateString = "${bet365.football.delay}")
	public void taskGame() {
		// 리그 정보가 없을 경우 리그를 받아 온다.
		if (leagueList.size() == 0) {
			this.leagueList.addAll(bet365Service.getLeagueList());
			return;
		}

		bet365Service.getGame(leagueList.remove(0));
	}
}
